import { SET_LANGUAGE } from './types';
import i18n from '../../i18n';
import AsyncStorage from '@react-native-async-storage/async-storage';

// 设置语言的action
export const setLanguage = (language: string) => {
  // 更新i18n实例的语言
  i18n.changeLanguage(language);
  
  // 保存语言设置到AsyncStorage
  AsyncStorage.setItem('language', language);
  
  return {
    type: SET_LANGUAGE,
    payload: language
  };
}; 